package com.burstly.lib.component.networkcomponent.burstly.html.mraid;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build.VERSION;
import com.burstly.lib.component.networkcomponent.burstly.OverlayContainer;
import com.burstly.lib.component.networkcomponent.burstly.OverlayContainer.IOverlayListener;
import com.burstly.lib.component.networkcomponent.burstly.html.IRichMediaAdListener;
import com.burstly.lib.util.LoggerExt;

class ExpandEvent extends AbstractParseParamsEvent<ExpandAndOrientationProperties>
  implements ContentLoaderWebView.IWebContentLoadedListener, OverlayContainer.IOverlayListener
{
  static final int EVENT_ID = 3;
  static final LoggerExt LOG = LoggerExt.getInstance();
  static final String STATE = "state";
  static final String TAG = ExpandEvent.class.getSimpleName();
  private ContentLoaderWebView mLoaderView;
  private MraidView mSecondPartView;
  private String mUrl;
  private MraidView mView;

  protected ExpandEvent()
  {
    super(ExpandAndOrientationProperties.class);
  }

  private void handleExpandResizeStates(ExpandAndOrientationProperties paramExpandAndOrientationProperties, Context paramContext)
  {
    if (this.mView.mViewState.getState() == MraidBridgeState.EXPANDED)
      return;
    OverlayContainer localOverlayContainer = this.mView.getOpenedOverlay();
    if (localOverlayContainer != null)
    {
      localOverlayContainer.hideOverlayed();
      this.mView.setOpenedOverlay(null);
    }
    if (this.mUrl == null)
    {
      MraidExpandedView localMraidExpandedView1 = new MraidExpandedView(this.mView);
      localMraidExpandedView1.setExpandedProperties(paramExpandAndOrientationProperties);
      localMraidExpandedView1.showOverlayed();
      this.mView.setOpenedOverlay(localMraidExpandedView1);
    }
    while (true)
    {
      this.mView.fireSimpleChangeEvent("state", MraidBridgeState.EXPANDED.name().toLowerCase());
      if (this.mView.mRichMediaListener != null)
        this.mView.mRichMediaListener.onExpand();
      this.mView.mViewState.setState(MraidBridgeState.EXPANDED);
      return;
      this.mLoaderView = new ContentLoaderWebView(paramContext);
      this.mLoaderView.setContentLoaderListener(this);
      this.mLoaderView.loadUrl(this.mUrl);
      this.mSecondPartView = new MraidView(paramContext);
      this.mSecondPartView.showLoadingBar();
      this.mSecondPartView.mViewState.setAfterLoadingStateMask(4);
      MraidExpandedView localMraidExpandedView2 = new MraidExpandedView(this.mSecondPartView);
      localMraidExpandedView2.setOverlayListener(this);
      localMraidExpandedView2.setExpandedProperties(paramExpandAndOrientationProperties);
      localMraidExpandedView2.showOverlayed();
      this.mSecondPartView.setOpenedOverlay(localMraidExpandedView2);
    }
  }

  @TargetApi(11)
  protected void cleanUp()
  {
    super.cleanUp();
    if (this.mSecondPartView != null)
    {
      if (Build.VERSION.SDK_INT >= 11)
        this.mSecondPartView.onPause();
      this.mSecondPartView = null;
    }
    if (this.mLoaderView != null)
    {
      this.mLoaderView.cancelLoading();
      this.mLoaderView.destroy();
      this.mLoaderView = null;
    }
  }

  public void onCloseOverlay()
  {
    try
    {
      this.mView.mViewState.setState(MraidBridgeState.DEFAULT);
      this.mView.fireSimpleChangeEvent("state", MraidBridgeState.DEFAULT.name().toLowerCase());
      this.mSecondPartView.destroy();
      this.mSecondPartView = null;
      if (this.mLoaderView != null)
      {
        this.mLoaderView.cancelLoading();
        this.mLoaderView.destroy();
      }
      this.mLoaderView = null;
      return;
    }
    catch (Exception localException)
    {
      LOG.logThrowable(TAG, localException);
    }
  }

  public void onFailedToLoad()
  {
    this.mView.fireErrorEvent("expand", "can not open provided url as MRAID script. Collapsing.");
    this.mSecondPartView.close();
  }

  public void onLoad(String paramString)
  {
    this.mSecondPartView.loadDataWithBaseURL(null, paramString, null, "utf8", null);
    this.mLoaderView = null;
  }

  public void onShowOverlay()
  {
  }

  public void parsed(ExpandAndOrientationProperties paramExpandAndOrientationProperties)
  {
    if (paramExpandAndOrientationProperties != null);
    switch (1.$SwitchMap$com$burstly$lib$component$networkcomponent$burstly$html$mraid$MraidBridgeState[this.mView.mViewState.getState().ordinal()])
    {
    default:
      return;
    case 1:
    case 2:
    }
    handleExpandResizeStates(paramExpandAndOrientationProperties, this.mView.getContext());
  }

  protected boolean setUpEvent(MraidView paramMraidView, Object[] paramArrayOfObject)
  {
    this.mView = paramMraidView;
    this.mUrl = ((String)paramArrayOfObject[1]);
    return (!paramMraidView.isInterstitial()) && (paramMraidView.mViewState.getState() != MraidBridgeState.EXPANDED);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.mraid.ExpandEvent
 * JD-Core Version:    0.6.2
 */